package xiangmu.schoolpaper.controller.system;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xiangmu.schoolpaper.pojo.VO.TemplateOneVO;
import xiangmu.schoolpaper.result.Result;
import xiangmu.schoolpaper.service.impl.system.TemplateOneServiceImpl;

@Slf4j
@RestController
@RequestMapping("/system")
@Tag(name="模板信息表和参数表的查看和修改")
public class TemplateOneController {
    @Autowired
    private TemplateOneServiceImpl templateOneServiceImpl;


    @GetMapping("/get/template")
    @Operation(summary = "根据学院、专业和模板类型查询信息")
    public Result getTemplateByFacultyMajorAndType(
            @RequestParam String faculty,
            @RequestParam String major,
            @RequestParam String type) {
        log.info("查询学院为{}，专业为{}，模板类型为{}的模板信息", faculty, major, type);
        TemplateOneVO template = templateOneServiceImpl.getTemplateByFacultyMajorAndType(faculty, major, type);
        return Result.success(template);
    }

    @GetMapping("/get/template0ne")
    @Operation(summary = "查询模板信息")
    public Result gettemplateById(Integer id) {
        log.info("查询id为{}的模板信息", id);
        TemplateOneVO template = templateOneServiceImpl.gettemplateById(id);
        return Result.success(template);
    }
    //查看某一条模板评分参数
    @GetMapping("/get/parameterOne")
    @Operation(summary = "查询模板评分参数信息")
    public Result getparameterById(Integer id) {
        log.info("查询id为{}的模板参数信息", id);
        TemplateOneVO template = templateOneServiceImpl.getparameterById(id);
        return Result.success(template);
    }

    //修改模板基本信息
    @PostMapping("/update/template")
    @Operation(summary = "修改模板参数信息")
    public Result updatetemplate(@RequestBody TemplateOneVO template) {
        log.info("修改模板信息{}", template);
        templateOneServiceImpl.updatetemplate(template);
        return Result.success();
    }
}
